import { Button } from 'ant-design-vue';
import type { FormSchema } from '@/components/core/schema-form/';
import { UploadOutlined } from '@ant-design/icons-vue';
import { useUserStore } from '@/store/modules/user';
import constants from '@/utils/constants';

export const schemas: FormSchema[] = [
  {
    field: 'msg',
    component: 'InputTextArea',
    label: '审核意见',
    colProps: {
      span: 12,
    },
  },
  {
    field: 'fileList',
    component: 'Upload',
    label: '审核附件',
    colProps: {
      span: 12,
    },
    componentProps: {
      maxCount: 1,
      action: '/api/' + constants.uploadfiles + '?access_token=' + useUserStore().token,
    },
    componentSlots: {
      default: () => (
        <Button>
          <UploadOutlined /> 点击上传
        </Button>
      ),
    },
  },
  {
    field: 'user',
    component: 'Input',
    label: '审批人',
    colProps: {
      span: 12,
    },
    defaultValue: useUserStore().name,
    componentProps: {
      disabled: true,
    },
  },
  {
    field: 'rdt',
    component: 'Input',
    label: '审批时间',
    colProps: {
      span: 12,
    },
    defaultValue: getTime(),
    componentProps: {
      disabled: true,
    },
  },
];

function getTime() {
  let yy = new Date().getFullYear();
  var mm =
    new Date().getMonth() < 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1;
  var dd = new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate();
  let hh = new Date().getHours();
  let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
  let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
  return yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss;
}
